#Harris 1974 Watergate Survey, study no. 2434
require("dplyr")
require("readstata13")

## set working directory
## to replication package

## download data
survey <- read.dta13("Harris_Data/Harris 1974 Watergate Survey, study no. 2434/harris_s2434_spss.dta")


## pid
survey$pid <- c(1:nrow(survey))
class(survey$pid)

## study number
survey$study <- as.character(2434)
class(survey$study)

## year
survey$year <- 1974
class(survey$year)

## geographpic data
survey$urban <- as.character(survey$S13)
summary(survey$urban)

## region 
survey$region <- as.character(survey$S11)
summary(survey$region)

## respondent name
summary(survey$F1)
survey$hh <- as.character(survey$F1)

## inequality increasing
summary(survey$Q7_B)
survey$inequality <- as.character(survey$Q7_B)
summary(survey$inequality)

class(survey$inequality)
is.ordered(survey$inequality)

## inequality variable version
survey$inequality.variable <- 1
class(survey$inequality.variable)


## union 
## included responses to each option
## in separate variables: 
survey$union.self <- as.character(survey$F6_1)
survey$union.self[survey$F6_4 == "Yes"] <- "Not Sure"

survey$union.other <- as.character(survey$F6_2)
survey$union.other[survey$F6_4 == "Yes"] <- "Not Sure"

## Are you employed? what kind of employment?
summary(survey$F2A)
survey$employed <- as.character(survey$F2A)
summary(survey$employed)

## empl
survey$employed.self <- NA

## Occupation
summary(survey$F2B)
survey$occupation <- as.character(survey$F2B)
summary(survey$occupation)

## occ self
survey$occupation.self <- NA

## household size
survey$hhsize <- NA

## Education
summary(survey$F5)
survey$educ <- as.character(survey$F5)

## Income
summary(survey$F7)
survey$income <- as.character(survey$F7)

## Age 
summary(survey$F4)
survey$age <- as.character(survey$F4)
summary(survey$age)

## race
summary(survey$F10)
survey$race <- as.character(survey$F10)
summary(survey$race)

## politics 
survey$party <- as.character(survey$Q4A)
summary(survey$party)
class(survey$party)

## ideology
survey$ideology <- NA
summary(survey$ideology)

## gender
summary(survey$F11)
survey$gender <- as.character(survey$F11)
table(survey$gender)

## religion
survey$religion <- as.character(survey$F8)
summary(survey$religion)

## factuals
survey$factual1 <- NA
survey$factual2 <- NA
survey$factual3 <- NA

## alienation index
survey$dontcare <- as.character(survey$Q7_A)
survey$dontcount <- as.character(survey$Q7_C)
survey$leftout <- as.character(survey$Q7_D)

## question place
survey$question_place <- "after party"

### put together data set
survey_2434 <- survey[,c("pid", "study", "year", "urban", "region", "hh",
                         "inequality", "inequality.variable", "union.self", "union.other",
                         "employed", "employed.self", "occupation", "occupation.self", "hhsize", "educ", "income", 
                         "age", "race", "party", "ideology", "gender", "religion",
                         "factual1", "factual2", "factual3", "dontcare", "dontcount", "leftout",
                         "question_place")]

## save dataset in folder (i.e. working directory must be set to folder)
#saveRDS(survey_2434, file = "Harris_Data/survey_2434.rds")



